package com.huaxin.hxenum.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.huaxin.hxenum.base.BaseCodeEnum;

/**
 * 通知发送状态枚举类
 */
public enum NotificationSendStatus implements BaseCodeEnum<String> {

    PENDING("pending", "待发送"),
    SENT("sent", "已发送"),
    FAILED("failed", "发送失败");


    @EnumValue
    private final String code;
    private final String displayName;

    NotificationSendStatus(String code, String displayName) {
        this.code = code;
        this.displayName = displayName;
    }

    @JsonValue
    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDisplayName() {
        return displayName;
    }

    public static NotificationSendStatus of(String code) {
        if (code == null) return null;
        for (NotificationSendStatus s : values()) {
            if (s.getCode().equalsIgnoreCase(code)) return s;
        }
        return null;
    }

    public static boolean isValid(String code) {
        return of(code) != null;
    }
}
